23 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
24 #define For(i, a, b) for (int i=(a); i<(b); ++i)
25 #define D(x) cout << #x " is " << x << endl
28 vector
< pair
<long double, long double> > angles
;
30 void shoot(const long double &begin
, const long double &end
, const int &index
){
32 if (index
< angles
.size() - 1){
33 long double begin_next
= angles
[index
+ 1].first
;
34 if (begin_next
>= begin
and begin_next
<= end
)
35 shoot(begin_next
, min(end
, angles
[index
+ 1].second
) , index
+ 1);
46 for (int i
= 0; i
< B
; i
++){
48 cin
>> x1
>> y1
>> x2
>> y2
;
49 //Convert to polar coordinates
50 long double angle1
= atan2((long double) y1
, (long double) x1
);
51 long double angle2
= atan2((long double) y2
, (long double) x2
);
52 angles
.push_back(make_pair(min(angle1
, angle2
), max(angle1
,angle2
) ));
54 sort(angles
.begin(), angles
.end());
56 /*for (int i = 0; i < B; i++){
57 cout << angles[i].first << " " << angles[i].second << endl;
60 for (int i
= 0; i
< B
; i
++) shot
[i
] = false;
62 for (int i
= 0; i
< B
; i
++){
64 //printf("Shot billboard number %d\n", i);
66 shoot(angles
[i
].first
, angles
[i
].second
, i
);
69 cout
<< shots
<< endl
;